unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, frxClass, frxDBSet, DB, ADODB, StdCtrls, frxDesgn, Grids,
  DBGrids, GridsEh, DBGridEh,frxRich;

type
  TForm1 = class(TForm)
    ADOTable1: TADOTable;
    frxDBDataset1: TfrxDBDataset;
    frxDesigner1: TfrxDesigner;
    OpenDialog1: TOpenDialog;
    Button2: TButton;
    Label2: TLabel;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    ComboBox1: TComboBox;
    CheckBox1: TCheckBox;
    Button3: TButton;
    OpenDialog2: TOpenDialog;
    Label3: TLabel;
    DataSource1: TDataSource;
    ADOTable1SPM: TWideStringField;
    ADOTable1SL: TFloatField;
    ADOTable1DJ: TWideStringField;
    ADOTable1YS: TWideStringField;
    ADOTable1SPHH: TWideStringField;
    ADOTable1GM: TWideStringField;
    ADOTable1CD: TWideStringField;
    ADOTable1DW: TWideStringField;
    ADOTable1YJ: TWideStringField;
    ADOTable1EMPTY: TWideStringField;
    ADOTable1GG: TWideStringField;
    ADOTable1SPXT: TWideStringField;
    ADOTable1CC: TWideStringField;
    ADOTable1VCPXZ: TWideStringField;
    ADOTable1VZXBZ: TWideStringField;
    ADOTable1TXM: TWideStringField;
    ADOTable1BZQ: TWideStringField;
    ADOTable1VGBENAME: TWideStringField;
    ADOTable1VSPDJ: TWideStringField;
    ADOTable1VGBMEMO: TWideStringField;
    ADOTable1VGBMANAMOD: TWideStringField;
    ADOTable1VGBISWEB: TWideStringField;
    ADOTable1VGBSPKS: TWideStringField;
    ADOTable1VGBSPDC: TWideStringField;
    ADOTable1VGBSPXB: TWideStringField;
    ADOTable1VGBSYNL: TWideStringField;
    ADOTable1VGBSYJJ: TWideStringField;
    ADOTable1VGBZCSB: TWideStringField;
    ADOTable1VGBPZWH: TWideStringField;
    ADOTable1VGBSCCS: TWideStringField;
    ADOTable1VGBZCFF: TWideStringField;
    ADOTable1VGBBZYJTS: TFloatField;
    ADOTable1VGBSUPID: TWideStringField;
    ADOTable1VGBWMID: TWideStringField;
    ADOTable1VGBNUM5: TFloatField;
    ADOTable1VGBSTR2: TWideStringField;
    ADOTable1VGBFZUNIT: TWideStringField;
    Button4: TButton;
    ADOTable2: TADOTable;
    DataSource2: TDataSource;
    DBGrid2: TDBGrid;
    Button5: TButton;
    ADOQuery1: TADOQuery;
    Button1: TButton;
    DBGridEh1: TDBGridEh;
    frxReport1: TfrxReport;
    frxRichObject1: TfrxRichObject;
    procedure Button1Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);

begin
 // ADOTable1.Close;
 // ADOTable1.Open;
  //frxReport1.LoadFromFile(cbb_paper_sty.Text+'G.FR3');
  if CheckBox1.Checked then begin
    frxReport1.FindObject('memo1').Font.Size := StrToInt(ComboBox1.Text);
  end;
  frxDBDataset1.DataSet := ADOTable1;
  frxReport1.ShowReport(true);
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 // ShowMessage(inttostr(Key)) ;
  if Key = 122 then begin
    frxReport1.DesignReport;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  OpenDialog1.Execute;
  frxReport1.LoadFromFile(OpenDialog1.FileName);
  Label2.Caption := ExtractFileName(frxReport1.FileName);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  frxReport1.LoadFromFile('8G.fr3');
  Label2.Caption := frxReport1.FileName;
  ComboBox1.Enabled := False;

end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked then begin
    ComboBox1.Enabled := True;
  end
  else begin
    ComboBox1.Enabled := False;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  OpenDialog2.Execute;
  ADOTable1.Close;
  ADOTable1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + ExtractFilePath(OpenDialog2.FileName)
    + ';Extended Properties=dbase 5.0;Persist Security Info=False';
  ADOTable1.TableName := OpenDialog2.FileName;
  Label3.Caption := ADOTable1.TableName;
  try
    ADOTable1.Open;
  except
  end;

 // frxReport1.LoadFromFile(OpenDialog1.FileName);
 // Label3.Caption :=ExtractFileName(frxReport1.FileName);
end;


procedure TForm1.Button4Click(Sender: TObject);

begin
 { ADOTable2.Close;
   ADOTable2.Open;
  ADOTable2.First;
  while not ADOTable2.Eof do begin
    ADOTable2.Delete;
    ADOTable2.Next;
  end;

  ADOTable2.Close;
  ADOTable2.Open;
  if DBGrid1.SelectedRows.Count > 0 then
    with DBGrid1.DataSource.DataSet do
    for i := 0 to DBGrid1.SelectedRows.Count - 1 do begin
      GotoBookmark(pointer(DBGrid1.SelectedRows.Items[i]));
      DBGrid2.DataSource.DataSet.Append;
      for j:=0 to ADOTable2.FieldCount -1 do begin
       DBGrid2.DataSource.DataSet.Fields[j].Value := Fields[j].Value;
      end;
     // DBGrid2.DataSource.DataSet.Fields[0].Value := Fields[0].Value;
         end; }
  if CheckBox1.Checked then begin
    frxReport1.FindObject('memo1').Font.Size := StrToInt(ComboBox1.Text);
  end;
  frxDBDataset1.DataSet := ADOTable2;
  frxReport1.ShowReport(true);
end;

procedure TForm1.Button5Click(Sender: TObject);
var
  i, j: Integer;
begin
  ADOTable2.Close;
  ADOQuery1.Close;
  ADOQuery1.SQL.Clear;
  ADOQuery1.SQL.Add('delete from jgp');
  ADOQuery1.ExecSQL;
  ADOTable2.Open;
  if DBGrideh1.SelectedRows.Count > 0 then
    with DBGrideh1.DataSource.DataSet do
      for i := 0 to DBGrideh1.SelectedRows.Count - 1 do begin
        GotoBookmark(pointer(DBGrideh1.SelectedRows.Items[i]));
        DBGrid2.DataSource.DataSet.Append;
        for j := 0 to ADOTable2.FieldCount - 1 do begin
          DBGrid2.DataSource.DataSet.Fields[j].Value := Fields[j].Value;
        end;
     // DBGrid2.DataSource.DataSet.Fields[0].Value := Fields[0].Value;
      end;
end;

end.

